package com.java.array;

import java.util.Scanner;

public class ArrayDemo5 {
    public static void main(String[] args) {
        int[][] score = new int[3][5];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < score.length; i++) {
            System.out.println("第"+(i+1)+"个班的成绩：");
            for (int j = 0; j < score[i].length; j++) {
                System.out.println("第"+(j+1)+"个同学的成绩是：");
                score[i][j] = scanner.nextInt();
            }
            System.out.println();
        }
        for (int i = 0; i < score.length; i++) {
            //内层循环控制下标
            for (int j = 0; j < score[i].length; j++) {
                //访问每一个元素
                System.out.print(score[i][j] + "\t");
            }
            System.out.println();
        }

        int a = 0;
        for (int i = 0; i < score.length; i++) {
            int score1 = 0;
            for (int j = 0; j < score[i].length; j++) {
                score1 += score[i][j];
            }
            int score3  = 0;
            score3 = score1/score[i].length;
            a = i+1;
            System.out.println("第"+a+"个班的平均成绩为"+score3);
        }
        int score3 = 0;
        for (int i = 0; i < score.length; i++) {
            for (int j = 0; j < score[i].length; j++) {
                score3 += score[i][j];
            }
        }
        int score4 = score3/15;
        System.out.println("总平均成绩为："+score4);

    }
}
